import Vue from "vue";
import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";

import "@/icons"; // icon
import "@/permission"; // permission control
Vue.config.devtools = true;

// 打印机
import Print from "vue-print-nb";
// Global instruction
Vue.use(Print);

// 注册全局混入
import { roleObj } from "@/mixins";
Vue.mixin(roleObj);

import * as obj from "./disrectives";
for (let key in obj) {
  Vue.directive(key, obj[key]);
}
// 全局组件卡片
import cmds from "@/components";
Vue.use(cmds);

// 导入所有函数到一个对象里
import * as filters from "./filters";
// 再遍历这个对象，注册成过滤器
for (let key in filters) {
  Vue.filter(key, filters[key]);
}

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale });
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI);

Vue.config.productionTip = false;

import i18n from "@/i18n";

Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
});
new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: h => h(App)
});
